<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="cn.firstsoft.firstframe.admin.*"%>
<%
  LogFileBean lfb = new LogFileBean();
  lfb.load();
  
  String loggerFirstsoft[] = null;
  String loggerSpringside[] = null;
  // request.getParameter("")==null?"":request.getParameter("")
  
  if("1".equals(request.getParameter("firstsoft"))){
    //启用firstsoft日志
    loggerFirstsoft =  request.getParameterValues("firstsoftCheckBox");
  }
  
  if("1".equals(request.getParameter("springside"))){
    //启用firstsoft日志
    loggerSpringside = request.getParameterValues("springsideCheckBox");
  }
  
  String firstsoftDetail ="";
  String springsideDetail = "";


  for(int i = 0; loggerFirstsoft!= null&&loggerFirstsoft.length > i;i++ ){
     firstsoftDetail += ("," + loggerFirstsoft[i]);
  }

  for(int j = 0; loggerSpringside!= null&&loggerSpringside.length > j;j++ ){
     springsideDetail += ("," + loggerSpringside[j]);
  }

  if(firstsoftDetail.length()>0)
    lfb.setLoggerFirstsoft("INFO"+firstsoftDetail);
  else 
    lfb.setLoggerFirstsoft("");
  if(springsideDetail.length()>0)
    lfb.setLoggerSpringside("INFO"+springsideDetail);
  else 
    lfb.setLoggerSpringside("");
  
  
  String url = "";
  if("oracle".equals(request.getParameter("dbtype"))){
    lfb.getDB().setDriver(LogDbDetail.ORACLE_DRIVER);
    lfb.getDB().setSql(LogDbDetail.ORACLE_SQL);
    url = "jdbc:oracle:thin:@"+ request.getParameter("ip") +":"+ request.getParameter("port") +":"+ request.getParameter("serverName"); 
  } else if("sqlserver".equals(request.getParameter("dbtype"))){
    lfb.getDB().setDriver(LogDbDetail.MS_DRIVER);
    lfb.getDB().setSql(LogDbDetail.MS_SQL);
    url = "jdbc:jtds:sqlserver://"+ request.getParameter("ip") +":"+request.getParameter("port")+";DatabaseName="+request.getParameter("serverName");
  }
  
  lfb.getDB().setURL(url);  
  lfb.getDB().setUser(request.getParameter("dbuser"));
  lfb.getDB().setPassword(request.getParameter("dbpassword"));

  
  if(lfb.save()){
    //保存成功
    response.sendRedirect("logger_log4j.jsp");
    // out.println("保存成功");
  } else {
    //保存失败
    //out.println("保存成功");
    response.sendRedirect("logger_log4j.jsp");
  }
  
  
  
  /*
  //lfb.setLoggerFirstsoft("");
  //lfb.setLoggerSpringside("");
   
  lfb.getDB().setUser("");
  lfb.getDB().setPassword("");
  //lfb.getDB().setDriver("");
  //lfb.getDB().setURL("");
  //lfb.getDB().setSql("");
  
  lfb.save();
  */

%>